var t = require("../../../../../../@babel/runtime/helpers/objectSpread2"), a = getApp();

Component({
    properties: {
        keywork: {
            type: null
        },
        memberId: {
            type: null
        }
    },
    data: {
        strUrl: "plugin.wechat-chat-sidebar.frontend.controller.customer.customer.income-record",
        getConfig: {
            client: "work",
            type: 17
        },
        showTypeSheet: !1,
        actions: [],
        recordList: [],
        statistic: [],
        revenueType: 0,
        json: {
            page: 1,
            income_type: "",
            status: ""
        },
        typeText: "",
        loading: !1,
        finished: !1
    },
    lifetimes: {
        attached: function() {
            var t = wx.getStorageSync("langIndex");
            this.setData({
                language: t.en
            }), this.getData();
        }
    },
    methods: {
        getData: function() {
            var e = this;
            if (!this.data.finished || !this.data.loading) {
                var s = {};
                0 == this.data.revenueType ? (s = {
                    page: this.data.json.page,
                    income_type: this.data.json.income_type
                }, "customer" == this.data.keywork && (this.data.strUrl = "plugin.customer-center.frontend.controllers.customer.income-record", 
                s.member_id = this.data.memberId)) : (s = {
                    page: this.data.json.page,
                    status: this.data.json.status
                }, "customer" == this.data.keywork && (this.data.strUrl = "plugin.customer-center.frontend.controllers.customer.get-withdraw-log", 
                s.member_id = this.data.memberId));
                var i = t({}, s);
                "customer" == this.data.keywork && (i = t({}, s)), this.loading = !0;
                var n = a.getNetAddresss(this.data.strUrl);
                a._postNetWork({
                    url: n,
                    data: i,
                    success: function(t) {
                        var a = t.data;
                        1 == a.result && a.data.data ? (console.log(a), (e.data.json.page >= a.data.last_page || a.data.data.length < a.data.per_page) && e.setData({
                            finished: !0
                        }), e.data.recordList = e.data.json.page > 1 ? e.data.recordList.concat(a.data.data) : a.data.data, 
                        0 === e.data.actions.length && e.setActions(a.data.income_type), e.data.statistic = a.data.get_withdraw, 
                        e.data.json.page = ++e.data.json.page, e.setData({
                            recordList: e.data.recordList,
                            statistic: e.data.statistic,
                            "json.page": e.data.json.page
                        })) : (e.setData({
                            finished: !0
                        }), wx.showToast({
                            icon: "none",
                            title: a.msg,
                            duration: 1500
                        }));
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        },
        loadMore: function() {
            this.getData();
        },
        setActions: function(t) {
            var a = [];
            for (var e in t) a.push({
                name: t[e].title,
                value: t[e].type
            });
            a.unshift({
                name: "默认选项",
                value: "",
                color: "#8f8686"
            }), this.setData({
                actions: a
            });
        },
        changeRevenueType: function(t) {
            var a = t.detail.name;
            this.setData({
                revenueType: a,
                "json.income_type": ""
            }), this.paramsInit(), this.getData();
        },
        changeTabsStatus: function(t) {
            var a = t.detail.name;
            this.setData({
                "json.status": a,
                "json.page": 1,
                loading: !1,
                finished: !1,
                recordList: []
            }), this.getData();
        },
        search: function(t) {
            this.paramsInit(), this.getData();
        },
        paramsInit: function() {
            this.setData({
                "json.page": 1,
                loading: !1,
                finished: !1,
                recordList: [],
                statistic: []
            });
        },
        onSelect: function(t) {
            this.setData({
                typeText: t.detail.name,
                showTypeSheet: !1,
                "json.income_type": t.detail.value
            });
        },
        showTypeSheetShow: function() {
            this.setData({
                showTypeSheet: !0
            });
        }
    }
});